package route

import (
	"github.com/gin-gonic/gin"
	"library/controller"
	"library/filter"
)

func RegisterRoute(r *gin.Engine) *gin.Engine {
	r.POST("/register", controller.Register)
	r.POST("/login", controller.Login)

	// 注册用户相关操作路由组
	routeUser := r.Group("/user", filter.AuthenticationFilter())
	{
		routeUser.GET("/info", controller.Info)			//获取用户信息
		routeUser.POST("/borrow", controller.Borrow)		//借书
		routeUser.POST("/return", controller.ReturnBook)	//还书
	}
	// 注册管理员相关图书操作相关路由组
	routeAdmin := r.Group("/admin", filter.AuthenticationFilter())
	{
		routeAdmin.POST("/add", controller.AddNewBook)		//上架
		routeAdmin.PUT("/update", controller.UpdateBook)		//更新 TODO
		routeAdmin.DELETE("/delete", controller.DeleteBook)	//下架
	}
	return r
}